package org.test.demo.pattern.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class JdkDynamicProxyUtil {
    public static <T> T newProxyInstance(T targetObj, InvocationHandler handler){
        ClassLoader classLoader = targetObj.getClass().getClassLoader();
        Class<?>[] interfaces = targetObj.getClass().getInterfaces();
        return (T)Proxy.newProxyInstance(classLoader,interfaces,handler);
    }
}

